home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / network / lattice / portlib.lzh / PORTLIB / SPRINTF.C < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-10  |  679 b   |  39 lines

  1. #include <stdarg.h>
  2. #include <stdio.h>
  3. #include <limits.h>
  4.  
  5. static int sputc (int ch, FILE *fp);
  6. extern int _doprnt (int (*)(int, FILE *), FILE *, const char *, va_list);
  7.  
  8. static int
  9. sputc (ch, fp)
  10.     int ch;
  11.     FILE *fp;
  12. {
  13.     char **bufp = (char **) fp;
  14.     *(*bufp)++ = ch;
  15.     return ch & 0xff;
  16. }
  17.  
  18. int __sprintf (char *buf, const char *fmt, ...)
  19. {
  20.     register int n;
  21.     va_list argp;
  22.  
  23.     va_start(argp, fmt);
  24.     n = _doprnt(sputc, (FILE *) &buf, fmt, argp);
  25.     *buf = '\0';
  26.     return(n);
  27. }
  28.  
  29. int __vsprintf (buf, fmt, args)
  30.     char *buf;
  31.     const char *fmt;
  32.     va_list args;
  33. {
  34.     register int n;
  35.     n = _doprnt(sputc, (FILE *) &buf, fmt, args);
  36.     *buf = '\0';
  37.     return(n);
  38. }
  39.